package com.umgsai.thread.thread29;

public class Service {
	public void testWaitMethod(Object lock) {
		try {
			synchronized (lock) {
				System.out.println(Thread.currentThread().getName() + " begin wait " + System.currentTimeMillis());
				lock.wait();
				System.out.println(Thread.currentThread().getName() + " end wait " + System.currentTimeMillis());
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public void testNotifyMethod(Object lock) {
		try {
			synchronized (lock) {
				System.out.println(Thread.currentThread().getName() + " begin notify " + System.currentTimeMillis());
				lock.notify();
				Thread.sleep(2000);
				System.out.println(Thread.currentThread().getName() + " end notify " + System.currentTimeMillis());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}	
	}
}
